<include file="Public:header" />
<div class="container no-mar-top no-bg">
	<div class="row " >
		<div class="span2 bs-docs-sidebar mar-left3" >
			<ul class="nav nav-list bs-docs-sidenav span2 widths" id="left_list" style="min-height:380px;">
				<li class="first-li"><span class="spans1" ><img src="__PUBLIC__/img/house.png"/>线索详情</span></li>
				<li class="active"><a href="#tab1">{:L('BASIC_INFO')}</a></li>
				<li><a href="#tab2">{:L('COMMUNICATION_LOG')}&nbsp;&nbsp;<span class="badge badge-success"><if condition="$leads['log_count']">{$leads['log_count']}</if></span></a></li>
				<li><a href="#tab6">{:L('OWNER_LOG')}&nbsp;&nbsp;<span class="badge badge-success"><if condition="$leads['record_count']">{$leads['record_count']}</if></span></a></li>
				<li><a href="#tab4">{:L('TASK')}&nbsp;&nbsp;<span class="badge badge-success"><if condition="$leads['task_count']">{$leads['task_count']}</if></span></a></li>
				<li><a href="#tab5">{:L('EVENT')}&nbsp;&nbsp;<span class="badge badge-success"><if condition="$leads['event_count']">{$leads['event_count']}</if></span></a></li>
				<li><a href="#tab3">{:L('FILE')}&nbsp;&nbsp;<span class="badge badge-success"><if condition="$leads['file_count']">{$leads['file_count']}</if></span></a></li>
			</ul>
		</div>
		<div class="tab-content span8 mar-lefts" >
			<div class="tab-pane fade in active" id="tab1">
				<div class="container2 top-pad" >
					<a class="basic_information" name="tab">线索详情</a>
					<div class="pull-right"style="margin:-3px 15px 0 0;">
						<a href="{:U('leads/edit','id='.$leads['leads_id'])}" class="btn btn-primary">{:L('EDIT')}</a>
						<a href="{:U('leads/delete','id='.$leads['leads_id'])}" class="btn btn-primary del_confirm">{:L('DELETE')}</a>
						<a href="javascript:void(0)" class="btn btn-primary" onclick="javascript:history.go(-1)">{:L('RETURN')}</a>
					</div>
				</div>
				<div class="back_box" style="margin-top:10px;">
					<include file="Public:alert"/>
					<table class="table table-hover">
						<tbody>
							<tr>
								<td class="tdleft" width="15%">{:L('CREATE_TIME')}</td>
								<td><if condition="$leads['create_time'] neq 0">{$leads.create_time|date='Y-m-d H:i:s',###}</if></td>
								<td class="tdleft">{:L('CREATOR_ROLE')}</td>
								<td><a class="role_info" href="javascript:void(0)" rel="{$leads.creator.role_id}">{$leads.creator.user_name}</if></a></td>
							</tr>
							<tr>
								<td class="tdleft">{:L('OWNER_ROLE')}</td>
								<td><a class="role_info" href="javascript:void(0)" rel="{$leads.owner.role_id}">{$leads.owner.user_name}</if></a></td>
								<td class="tdleft" width="15%">{:L('LAST_MODIFIED_TIME')}</td>
								<td><if condition="$leads['update_time'] gt 0">{$leads.update_time|date='Y-m-d H:i:s',###}</if></td>
							</tr>
							<php>$j=0;</php>
							<volist name="field_list" id="vo">
							<php>$j++;</php>
							<if condition="$vo['form_type'] == 'textarea' or $vo['form_type'] == 'editor'">
								<if condition="$i%2 == 0">
								<td colspan="2">&nbsp;</td>
								</tr>
								</if>
								<tr>
									<td class="tdleft" width="15%">{$vo.name}:</td>
									<td colspan="3" style="word-break:break-word;">{$leads[$vo['field']]}</td>
								</tr>
								<if condition="$i%2 != 0 && count($field_list) != $j">
								<php>$i++;</php>
								</if>
							<else/>
								<if condition="$i%2 != 0">
								<tr>
								</if>
									<td class="tdleft" width="15%">{$vo.name}:</td>
									<td width="35%">
										<span style="color:#{$vo['color']}">
										<if condition="$vo['form_type'] eq 'datetime'">
											<if condition="$leads[$vo['field']] gt 0">{$leads[$vo['field']]|date='Y-m-d',###}</if>
										<elseif condition="$vo['form_type'] eq 'address'" />
											{$leads[$vo['field']]}
											<a href="javascript:void(0);" class="getMap" rel="{$leads[$vo['field']]}">
												<img src="__PUBLIC__/img/location.png" style="height:20px; vertical-align: text-bottom;">
											</a>
										<else />
											{$leads[$vo['field']]}
										</if>
										</span>
									</td>
								<if condition="$i%2 == 0">
								</tr>
								</if>
								<if condition="$i%2 != 0 && count($field_list) == $j">
									<td colspan="2">&nbsp;</td>
								</tr>
								</if>
							</if>
							</volist>
						</tbody>
					</table>
				</div>
			</div>
			<div class="tab-pane fade back_box" id="tab2">
				<!-- 线索详情 -->
				<div class="header1">
					<div class="pull-left two-title" >{:L('COMMUNICATION_LOG')}</div>
					<div class="pull-right"> <a href="javascript:void(0);" class="add_log btn btn-primary">{:L('ADD')}</a></div>
					<div style="clear:both;"></div>
				</div>
				<table class="table">
					<if condition="$leads.log eq null">
						<div class="mar-left2">
							{:L('EMPTY_TPL_DATA')}    
						</div>
					<else />
					<volist name="leads.log" id="vo">
						<div class="caption">
							{$vo.subject}
						</div>
						<div class="mar-left2">
							<if condition="strlen($vo['content']) gt 100">
								<div id="slog_{$vo.log_id}" class="pad-right3">
									{$vo.content|msubstr=###,0,100}
									<a class="more" rel="{$vo.log_id}" href="javascript:void(0)">{:L('VIEW_FULL_INFO')}</a>
								</div>
								<div id="llog_{$vo.log_id}" class="hide">
									<div class="pad-right3 pres" >{$vo.content}</div>
								</div>
							<else/>
								<div class="pad-right3 pres"> {$vo.content}</div>
							</if>
						</div>
						<if condition="$leads['is_deleted'] neq 1">
							<div class="editors">
								<if condition="$leads['is_deleted'] neq 1"><a href="javascript:void(0)" rel="{$vo.log_id}" class="edit_log">{:L('EDIT')}</a>&nbsp;<a href="{:U('log/delete','r=RLeadsLog&id='.$vo['log_id'])}" class="del_confirm">{:L('DELETE')}</a></if>&nbsp;&nbsp;&nbsp;&nbsp;
							
								<notempty name="vo.owner.user_name"><img style="margin-top:-3px;" src="__PUBLIC__/img/user.png">&nbsp;<a class="role_info name-colors" rel="{$vo.owner.role_id}" href="javascript:void(0)">{$vo.owner.user_name}</a>&nbsp;</notempty> &nbsp;<img src="__PUBLIC__/img/time_annoce.png"/>
								{$vo.create_date|date="Y-m-d  g:i ",###} &nbsp; 
								<notempty name="vo.create_date"> &nbsp; </notempty>
								<if condition="C('ismobile') eq 1"><br/></if>
							</div>
						</if>
					</volist>
					</if>
				</table>
			</div>
			<div class="tab-pane fade back_box" id="tab6">
				<div class="header1">
					<div class="pull-left two-title" >{:L('OWNER_LOG')}</div>
					<div style="clear:both;"></div>
				</div>
				<table class="table">
					<if condition="$leads.record eq null">
						<tr>
							<td>{:L('EMPTY_TPL_DATA')} </td>
						</tr>
					<else /> 
						<tr>
							<td>{:L('OWNER_ROLE')}</td>
							<td>{:L('RECEIVE_TIME')}</td>
						</tr>
						<volist name="leads.record" id="vo">
							<tr>
								<td>
									<notempty name="vo.owner.user_name"><a class="role_info" rel="{$vo.owner.role_id}" href="javascript:void(0)">{$vo.owner.user_name}</a></notempty>
								</td>
								<td>
									{$vo.start_time|date="Y-m-d",###}
								</td>
							</tr>
						</volist>
					</if>
				</table>
			</div>
			<div class="tab-pane fade back_box" id="tab4">
				<div class="header1">
					<div class="pull-left two-title" >{:L('RELATED_TASKS')}</div>
					<div class="pull-right"> 
					<if condition="$customer['is_deleted'] == 0">
						<if condition="$leads['is_deleted'] == 0"><a href="javascript:void(0);" class="add_task btn btn-primary">{:L('ADD')}</a></if>
					</if>
					</div>
					<div style="clear:both;"></div>
				</div>
				<table class="table">
					<if condition="$leads.task eq null">
						<tr>
							<td>{:L('EMPTY_TPL_DATA')}</td>
						</tr>
					<else /> 
						<tr>
							<td  width="12%">&nbsp;</td>
							<td>{:L('THEME')}</td>
							<if condition="C('ismobile') neq 1"><td>{:L('STATUS')}</td></if>
							<td>负责人</td>
							<td>任务相关人</td>
							<td>{:L('EXPIRATION_DATE')}</td>
							<if condition="C('ismobile') neq 1"><td>{:L('UPDATE_TIME')}</td></if>
						</tr>
						<volist name="leads.task" id="vo">
							<tr>
								<td class="tdleft">
									<if condition="$leads['is_deleted'] == 0"><a href="{:U('task/view','id='.$vo['task_id'])}">{:L('VIEW')}</a>&nbsp; <a href="{:U('task/delete','id='.$vo['task_id'])}" class="del_confirm">{:L('DELETE')}</a>&nbsp;
									<if condition="$vo.isclose eq 0"><a href="{:U('task/close','id='.$vo['task_id'])}">{:L('CLOSE')}</a><else /><a href="{:U('task/open','id='.$vo['task_id'])}">{:L('OPEN')}</a></if></if>
								</td>
								<td>
									<a href="{:U('task/view','id='.$vo['task_id'])}">{$vo.subject}</a>
								</td>
								<if condition="C('ismobile') neq 1">
								<td>
									{$vo.status}
								</td>
								</if>
								<td>
									<notempty name="vo.owner"><volist name="vo.owner" id="v"><a class="role_info" rel="{$v.role_id}" href="javascript:void(0)">{$v.user_name}</a>,</volist></notempty>
								</td>
								<td>
									<notempty name="vo.about_roles"><volist name="vo.about_roles" id="v"><a class="role_info" rel="{$v.role_id}" href="javascript:void(0)">{$v.user_name}</a>,</volist></notempty>
								</td>
								<td>
									<notempty name="vo.due_date">{$vo.due_date|date="Y-m-d H:i:s",###}</notempty>
								</td>
								<if condition="C('ismobile') neq 1">
								<td>
									<notempty name="vo.update_date">{$vo.update_date|date="Y-m-d H:i:s",###}</notempty>
								</td>
								</if>
							</tr>
						</volist>
					</if>
				</table>
			</div>
			<div class="tab-pane fade back_box" id="tab5">
				<div class="header1">
					<div class="pull-left two-title" >{:L('RELATED_EVENT')}</div>
					<div class="pull-right"> 
						<if condition="$leads['is_deleted'] == 0">
							<a href="javascript:void(0);" class="add_event btn btn-primary">{:L('ADD')}</a>
						</if>
					</div>
					<div style="clear:both;"></div>
				</div>
				<table class="table">
					<if condition="$leads.event eq null">
						<tr>
							<td>{:L('EMPTY_TPL_DATA')} </td>
						</tr>
					<else /> 
						<tr>
							<td width="12%">&nbsp;</td>
							<td>{:L('THEME')}</td>
							<td>{:L('EVENT_ADDRESS')}</td>
							<td>{:L('OWNER_ROLE')}</td>
							<if condition="C('ismobile') neq 1"><td>{:L('START_TIME')}</td>
							<td>{:L('END_TIME')}</td></if>
						</tr>
						<volist name="leads.event" id="vo">
							<tr>
								<td class="tdleft" >
									<if condition="$leads['is_deleted'] == 0"><a href="{:U('event/view','id='.$vo['event_id'])}">{:L('VIEW')}</a>&nbsp; <a href="{:U('event/delete','id='.$vo['event_id'])}" class="del_confirm">{:L('DELETE')}</a>&nbsp; 
									</if>
								</td>
								<td>
									{$vo.subject}
								</td>
								<td>
									{$vo.venue}
								</td>
								<td>
									<notempty name="vo.owner.user_name"><a class="role_info" rel="{$vo.owner.role_id}" href="javascript:void(0)">{$vo.owner.user_name}</a></notempty>
								</td>
								<if condition="C('ismobile') neq 1">
								<td>
									<notempty name="vo.start_date">{$vo.start_date|date="Y-m-d H:i:s",###}</notempty>
								</td>
								<td>
									<notempty name="vo.end_date">{$vo.end_date|date="Y-m-d H:i:s",###}</notempty>
								</td>
								</if>
							</tr>
						</volist>
					</if>
				</table>
			</div>
			<div class="tab-pane fade back_box" id="tab3">
				<div class="header1">
					<div class="pull-left two-title" >{:L('RELATED_FILE')}</div>
					<div class="pull-right"> 
					<if condition="$leads['is_deleted'] == 0">
						<a href="javascript:void(0);" class="add_file btn btn-primary">{:L('ADD')}</a>
					</if>
					</div>
					<div style="clear:both;"></div>
				</div>
				<table class="table">
					<if condition="$leads.file eq null">
						<tr>
							<td>{:L('EMPTY_TPL_DATA')} </td>
						</tr>
					<else /> 
						<tr>
							<td>&nbsp;</td>
							<td>{:L('FILE_NAME')}</td>
							<td>{:L('SIZE')}</td>
							<if condition="C('ismobile') neq 1"><td>{:L('ADDED_BY')}</td>
							<td>{:L('ADD_TIME')}</td></if>
						</tr>
						<volist name="leads.file" id="vo">
							<tr>
								<td class="tdleft">
									<if condition="$leads['is_deleted'] == 0">
										<a href="{:U('file/delete','r=RFileLeads&id='.$vo['file_id'])}" class="del_confirm">{:L('DELETE')}</a>
									</if>
								</td>
								<td>
									<a target="_blank" href="{$vo.file_path}">{$vo.name}</a>
								</td>
								<td>
									{$vo.size}{:L('BYTE')}
								</td>
								<if condition="C('ismobile') neq 1">
								<td>
									<notempty name="vo.owner.user_name"><a class="role_info" rel="{$vo.owner.role_id}" href="javascript:void(0)">{$vo.owner.user_name}</a></notempty>
								</td>
								<td>
									<notempty name="vo.create_date">{$vo.create_date|date="Y-m-d H:i:s",###}</notempty>
								</td>
								</if>
							</tr>
						</volist>
					</if>
				</table>
			</div>
		</div>
		<div class="span2  bs-docs-sidebar mar-lefts2" id="right_list">
			<ul class="nav nav-list bs-docs-sidenav  span2 widths" >
				<li class="first-li"><span class="spans1">编辑详情</span></li>
				<li><a href="javascript:void(0);" class="add_log"><img src="__PUBLIC__/img/youce.png"/>&nbsp;&nbsp;&nbsp;{:L('ADD_LOG')}</a></li>
				<li><a href="javascript:void(0);" class="add_task"><img src="__PUBLIC__/img/youce.png"/>&nbsp;&nbsp;&nbsp;{:L('ADD_TASK')}</a></li>
				<li><a href="javascript:void(0);" class="add_event"><img src="__PUBLIC__/img/youce.png"/>&nbsp;&nbsp;&nbsp;{:L('ADD_EVENT')}</a></li>
				<li><a href="javascript:void(0);" class="add_file"><img src="__PUBLIC__/img/youce.png"/>&nbsp;&nbsp;&nbsp;{:L('ADD_FILE')}</a></li>
				<if condition="$leads['is_transformed'] neq 1"><li><a  href="{:U('customer/add','leads_id='.$leads['leads_id'])}"><img src="__PUBLIC__/img/youce.png"/>&nbsp;&nbsp;&nbsp;{:L('CONVERT_TO_CUSTOMER')}</a></li></if>
			</ul>
		</div>
	</div>
</div>
<div class="hide" id="dialog-file" title="{:L('DIALOG_ADD_FILE')}">loading...</div>
<div class="hide" id="dialog-log" title="{:L('DIALOG_ADD_LOG')}">loading...</div>
<div class="hide" id="dialog-log-edit" title="{:L('DIALOG_EDIT_LOG')}">loading...</div>
<div class="hide" id="dialog-task" title="{:L('ADD_TASK')}">loading...</div>
<div class="hide" id="dialog-event" title="{:L('ADD_EVENT')}">loading...</div>
<div class="hide" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">loading...</div>
<div class="hide" id="dialog-map" title="{:L('MAP')}">loading...</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Z0Fo0ib1GUgWlylCWeLvQh2U"></script>
<script type="text/javascript">
	$('#left_list a').click(function (e) {
        e.preventDefault();
        $('#right_list').hide();
        $('#left_list').parent().next().removeClass('span8').addClass('span10');
        $(this).tab('show');
    })
    $('#left_list a:first').on('click', function (e) {
        $('#left_list').parent().next().removeClass('span10').addClass('span8');
        $('#right_list').show();
    })
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>

$("#dialog-file").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-log-edit").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-role-info").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-log").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-task").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-event").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-map").dialog({
    autoOpen: false,
    modal: true,
	width: 800,
	minHeight: 600,
	position: ["center",100]
});
$(".edit_log").click(function(){
	$log_id = $(this).attr('rel');
	$('#dialog-log-edit').dialog('open');
	$('#dialog-log-edit').load('{:U("log/edit","id=")}'+$log_id);
});
$("#dialog-role-list").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight: 400,
	buttons: {
		"Ok": function () {
			var item = $('input:radio[name="owner"]:checked').val();
			var name = $('input:radio[name="owner"]:checked').parent().next().html();
			$('#owner_name').val(name);
			$('#owner_id').val(item);
			$(this).dialog("close"); 
		},
		"Cancel": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});

$(".add_file").click(function(){
	$('#dialog-file').dialog('open');
	$('#dialog-file').load('{:U("file/add","r=RFileLeads&module=leads&id=".$leads["leads_id"])}');
});
$(".add_log").click(function(){
	$('#dialog-log').dialog('open');
	$('#dialog-log').load('{:U("log/add","r=RLeadsLog&module=leads&id=".$leads["leads_id"])}');
});
$(".add_task").click(function(){
	$('#dialog-task').dialog('open');
	$('#dialog-task').load('{:U("task/add","r=RLeadsTask&module=leads&id=".$leads["leads_id"])}');
});
$(".add_event").click(function(){
	$('#dialog-event').dialog('open');
	$('#dialog-event').load('{:U("event/add","r=REventLeads&module=leads&id=".$leads["leads_id"])}');
});
$(function(){
	$('#owner_name').click(
		function(){
			$('#dialog-role-list').dialog('open');
			$('#dialog-role-list').load("{:U('user/listDialog')}");
		}
	);
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
	$(".getMap").click(function(){
		var map = $(this).attr('rel');
		$('#dialog-map').dialog('open');
		$('#dialog-map').load('{:U("setting/mapdialog","map=")}'+map);
	});
	$(".more").click(function(){
		log_id = $(this).attr('rel');
		$('#llog_'+log_id).attr('class','');
		$('#slog_'+log_id).attr('class','hide');
	});
});
</script>
<include file="Public:footer" />